package com.neusoft.elmboot.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.neusoft.elmboot.mapper.BusinessMapper;
import com.neusoft.elmboot.mapper.RatingMapper;
import com.neusoft.elmboot.mapper.SellerMapper;
import com.neusoft.elmboot.po.Seller;
import com.neusoft.elmboot.service.SellerService;

@Service
public class SellerServiceImpl implements SellerService{

	@Resource
	private SellerMapper sellerMapper;
	
	@Resource
	private RatingMapper ratingMapper;
	
	@Resource BusinessMapper businessMapper;
	
	@Override
	public Seller getSellerById(Integer businessId) {
		Seller seller=sellerMapper.getSellerById(businessId);
		if(seller == null)seller = new Seller();
		seller.setRatingCount(ratingMapper.getRatingCountByBusinessId(businessId));
		seller.setScore(ratingMapper.getMeanScoreByBusinessId(businessId));
		seller.setName(businessMapper.getBusinessNameById(businessId));
		if(seller.getSellerId()!=null) {
			seller.setSupports(sellerMapper.listSupportBySellerId(seller.getSellerId()));
			seller.setPics(sellerMapper.listPicBySellerId(seller.getSellerId()));
			seller.setInfos(sellerMapper.listInfoBySellerId(seller.getSellerId()));
		}
		seller.setBusinessId(null);
		seller.setSellerId(null);
		return seller;
	}
	
}
